package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.pojo.Chamber;
import com.example.mapper.ChamberMapper;
import com.example.service.IChamberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.vo.ResultVo;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 会议室信息表 服务实现类
 * </p>
 *
 * @author wsl
 * @since 2022-04-24
 */
@Service
public class ChamberServiceImpl extends ServiceImpl<ChamberMapper, Chamber> implements IChamberService {

    @Override
    public PageInfo<Chamber> selectChamber(Integer maxCapacity, Integer status) {
//        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Chamber> wrapper = new QueryWrapper<>();
        wrapper.eq(maxCapacity!=null,"max_capacity",maxCapacity);
        wrapper.eq(status!=null,"status",status);
        List<Chamber> list= baseMapper.selectList(wrapper);
        return new PageInfo<>(list);
    }

    @Override
    public ResultVo addChamber(Chamber chamber) {
        int i = baseMapper.insert(chamber);
        return i >0 ? ResultVo.success("新增会议室成功") : ResultVo.error("新增会议室失败");
    }
    @Override
    public ResultVo selectChambers( ) {
        //查询可使用的会议室信息
        List<Chamber> list= baseMapper.selectChambers();
        return ResultVo.response(list);
    }



}
